<#assign module="marketing"/>

<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/bootstrap-multiselect.css">
<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
</@override>
<@override name="body">

	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					添加邀请新客户活动
					<#if type=="cash">
						(返现)
					<#elseif type="coupon">
						(返券)
					</#if>
					<label class="control-label"><font color="red">（带*表示必填项）</font></label>
			    </div>
			    <div class="panel-body">
    				<form id="submit_form" action="${ctx}/activity/create" class="form-horizontal" method="post">
		            	<input type="hidden" id="activityEvent" name="activityEvent" value="invite" />
		               	<@shiro.isMainCompany>
		               		<div class="form-group">
			                    <label class="col-sm-3 control-label"><em>*</em>所属公司：</label>
			                    <div class="col-sm-3">
			                    	<input type="hidden" id="companyNames" name="companyNames" value="" />
			                    	<select class="form-control" id="companyIds" name="companyIds" multiple="multiple" required>
			                    		<#if companys??>
			                    			<#list companys as company>
			                    				<option value="${company.id}">${company.abbreviation?if_exists}</option>
			                    			</#list>
			                    		</#if>
			                    	</select>
			                    </div>
			                </div>
		               	</@shiro.isMainCompany>
		                
		                <input type="hidden" id="activityType" name="activityType" value="${type}" />
			                
					    <#if type=="cash">
			                <div class="form-group">
			                    <label class="col-sm-3 control-label"><em>*</em>返现金额：</label>
			                    <div class="col-sm-3">
			                    	<input class="form-control" id="money" name="money" type="text"/>
			                    </div>
			                </div>
		                <#elseif type=="coupon">
			                <div class="form-group coupon_div" id="first_coupon_div">
			                	<input type="hidden" id="couponIds" name="couponIds" >
			                	<input type="hidden" id="couponAmounts" name="couponAmounts" >
			                	
			                    <label class="col-sm-3 control-label"><em>*</em>优惠劵：</label>
			                    <div class="col-sm-3">
			                    	<select class="form-control couponRule_select">
			                    		<option value="">--请选择--</option>
			                    		<#if coupons??>
				                    		<#list coupons as coupon>
				                    			<option value="${coupon.id}" eachLimit="${coupon.eachLimit}" numerAll="${coupon.number}">
				                    				${coupon.title?if_exists}
				                    				<#if coupon.timeStatus==0>
														(未开始)
													<#elseif coupon.timeStatus==1>
														(使用中)
													</#if>
				                    			</option>
				                    		</#list>
			                    		</#if>
			                    	</select>
			                    </div>
			                    <label style="float:left;" class="control-label"><em>*</em>数量：</label>
			                    <div class="col-sm-1">
			                    	<input class="form-control couponAmount" id="numbers" data-toggle="tooltip"  title="（小提示：所填数量为当前优惠券每人领取数量）" type="number" min="1" value="1"/>
			                    </div>
			                    <div class='col-sm-1'>
				                    <button type="button" id="add_coupon_rule" class="btn btn-default">
									  <span class="glyphicon glyphicon-plus-sign"></span> 添加
									</button>
								</div>
		                    </div>
		                </#if>
		                
		                <div class="form-group">
		                    <label class="col-sm-3 control-label"><em>*</em>有效期：</label>
		                    <div class="col-sm-3">
		                    	<input class="form-control" id="start" name="start" type="text" required/>
		                    	<span class="help-block">活动的开始时间，由该日期凌晨开始</span>
		                    </div>
		                    <label style="float:left;" class="control-label">-</label>
		                    <div class="col-sm-3">
		                    	<input class="form-control" id="end" name="end" type="text"/>
		                    	<span class="help-block">活动的结束时间，由该日期凌晨结束，不填写则不限制结束时间</span>
		                    </div>
		                </div>
		                
		                <div class="form-group">
					    	<label class="col-sm-3 control-label">通知方式：</label>
		                	<div class="col-sm-6">
		                		<p class="form-control-static">
									<label style="padding-right:12px;">
									  <input type="checkbox" name="messageType" value="sms" checked="checked"/> 短信
									</label>
									<label style="padding-right:12px;">
									  <input type="checkbox" name="messageType" value="message" checked="checked"/> 应用通知
									</label>
								</p>
								<span class="help-block">未使用客户端的用户不能收到应用通知，建议使用短信</span>
							</div>
					    </div>
		                
		                
		                <div class="form-group" style="margin-left:10px;">
		                	<label class="col-sm-3 control-label"></label>
			                <input id="submit_button" type="button" class="btn btn-primary" value="保存">
			                <input type="button" class="btn btn-default" onclick="window.location.href = '${ctx}/activity/list?event=invite&type=${type}';" value="返回">
			            </div>
			            
					</form>
        		</div>
			</div>
		</div>
	</div>

</@override>
<@override name="footer">
<script type="text/javascript">
$("#numbers").tooltip($("[data-toggle='tooltip']").tooltip());
	var main=false;
	<@shiro.isMainCompany>
		main=true;
	</@shiro.isMainCompany>
</script>
<script src="${ctx}/assets/js/bootstrap-multiselect.js"></script>
<script src="${ctx}/assets/js/bootstrap-datetimepicker.min.js"></script>
<script src="${ctx}/assets/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${ctx}/assets/js/activity/addinvite.js"></script>
</@override>
<@extends name="../layout.ftl"/>
